package com.haynes.meetxiaohai.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.haynes.meetxiaohai.entity.ShoppingCart;
import com.haynes.meetxiaohai.mapper.ShoppingCartMapper;
import com.haynes.meetxiaohai.service.ShoppingCartService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;

/**
 * @Author Haynes
 * @Date 2023/3/26 15:10
 * @PackageName:com.haynes.reggie.service.impl
 * @ClassName: ShoppingCartServiceImpl
 */
@Service
@Slf4j
public class ShoppingCartServiceImpl extends ServiceImpl<ShoppingCartMapper, ShoppingCart> implements ShoppingCartService {
    @Override
    public void clean(HttpSession session) {
        Long uid = (Long) session.getAttribute("user");

        LambdaQueryWrapper<ShoppingCart> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(ShoppingCart::getUserId, uid);

        this.remove(lambdaQueryWrapper);
    }
}
